//window.menu.hideSoftkeys();
			var city_url = 'http://testapp.cmdcmp.com/package/view_symbian/city.php?tpl=symbian&type=symbian3';
			var card_url = 'http://testapp.cmdcmp.com/package/view_symbian/jobs.php?tpl=symbian&type=symbian3';
			var search_url = 'http://testapp.cmdcmp.com/package/list.php?tpl=symbian&type=symbian3&area_id=1&app_type_root_id=2&app_type_id=8&action=search';
			var down_url = 'http://www.baidu.com/';
			var send_msg = '嗨，我正在使用广东移动的无线城市免费客户端，可精彩了：通过手机，海量新闻娱乐随时随地随意看；本地水电煤气查询、社保查询等众多便民服务可轻松办理。你也来体验一下吧，畅享无线轻松生活，点'+down_url+'下载。';
			
			var vertical_height = 60;
			var horizontal_height = 45;
			var frame="<iframe src='"+url+"' frameborder='0' onload='changeBg();' scrolling='auto' width='100%' height='"+(screen.height-vertical_height)+"px'  id='mainframe' name='mainframe'/>";
			var RunTime = 0;
			var RunTimes = 0;
			
			//window.onload = function(){
				//document.body.innerHTML = frame;
				//open_window();
			//};

			window.menu.setRightSoftkeyLabel('退出', function(){
				exit_widget();
			});
			window.menu.setLeftSoftkeyLabel('菜单', function(){
					open_window();
			});

			function exit_widget(){
				if(confirm("你确认要退出吗?")){
					window.close();
				}
			}

			function open_window(){
				if(document.getElementById("open_window") != null) document.body.removeChild(document.getElementById("open_window"));
				var str = '<img onclick="go_to(\''+city_url+'\');" src="images/city.png" />'+
						  '<img onclick="go_to(\''+card_url+'\');" src="images/card.png" />'+
						  '<img onclick="check_update();" src="images/update.png" />'+
						  '<img onclick="send_to_friend();" src="images/friend.png" />'+
						  '<img onclick="go_to_search(\''+search_url+'\');" src="images/search1.png" />'+
						  '<img onclick="page_reflesh();" src="images/refresh1.png" />'+
						  '<img onclick="exit_widget();" src="images/quit1.png" /></a>'+
						  '<img onclick="close_window();" src="images/cancel.png" />';
						  
				var container_div=document.createElement("div");
				container_div.id = "container";

				var window_div=document.createElement("div");
				window_div.id = "open_window";
				window_div.className = "window02";
				window_div.innerHTML = str;
				
				document.body.appendChild(container_div);
				document.body.appendChild(window_div);

				adjust_container();
			}

			function adjust_container(){
				if(document.getElementById("container") != null){
					document.getElementById("container").style.width = screen.width+"px";
					document.getElementById("container").style.height = screen.height+"px";
				}

				if(document.getElementById("open_window") != null){
					var left = (screen.width-parseInt(document.getElementById("open_window").offsetWidth))/2;
					var top = (screen.height-parseInt(document.getElementById("open_window").offsetHeight))/2;

					document.getElementById("open_window").style.left = left+"px";
					document.getElementById("open_window").style.top = top+"px";
				}
			}
			
			function go_to_search(go_search_url){
				setReturnButton(document.getElementById("mainframe").src);
				go_to(go_search_url);
			}

			function close_window(){
				if(document.getElementById("container") != null) document.body.removeChild(document.getElementById("container"));
				if(document.getElementById("open_window") != null) document.body.removeChild(document.getElementById("open_window"));
			}

			function page_reflesh(){
				document.getElementById("mainframe").src = document.getElementById("mainframe").src;
				close_window();
			}

			function go_to(url){
				document.getElementById("mainframe").src = url;
				close_window();
			}

			function ajax()
			{
				var xmlhttp = getXmlHttp();
				if(window.netscape) {
			    	netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");        
				}
				var url = update_url;
				xmlhttp.open("GET", url, true);
				xmlhttp.onreadystatechange = function ()
				{
					if (xmlhttp.readyState == 4)
					{
						if (xmlhttp.status == 200) 
						{
							document.body.innerHTML = frame;
							if(xmlhttp.responseText == 0){
							}
							else if(xmlhttp.responseText.slice(0,1) == '<'){ajax();}
							else
							{
								if(confirm("\u68C0\u6D4B\u5230\u65B0\u7248\u672C\uFF0C\u662F\u5426\u8FDB\u5165\u4E0B\u8F7D\u9875\u9762?"))
								{
									widget.openURL(xmlhttp.responseText);
									var WRT = window.open("", "_top");
									WRT.close();
								}else{}
							}
						}
					}
				};
				xmlhttp.send(null);
				function getXmlHttp()
				{
					var xml_http ;
					try 
					{
						// Firefox, Opera 8.0+, Safari
						xml_http = new XMLHttpRequest();
					} catch (e) 
					{
						// Internet Explorer
						try 
						{
							xml_http = new ActiveXObject("Msxml2.XMLHTTP");
						} catch (e) 
						{
							xml_http = new ActiveXObject("Microsoft.XMLHTTP");
						}
					}
					return xml_http;
				}
			}
			setTimeout(ajax,2000);
			function wait()
			{
				document.body.style.background='none';
			}

			var runHeight = 0;
			function resize(){
				if(runHeight!=screen.height){
					adjust_container();
					var add_height = vertical_height;
					if(runHeight>screen.height) add_height = horizontal_height;
					runHeight = screen.height;
					if (document.getElementById("mainframe") != null) document.getElementById('mainframe').height = runHeight-add_height;
				}

			}

			setInterval(resize, 1); 
     
			function checkAction() { 
				try {  
					var data = window.mainframe.location.hash ? window.mainframe.location.hash.substring(1) : '';
					if(data&&(app_info = getInfo(data))&&app_info['timestamp']!=RunTime){
						switch(app_info['action']){
							case 'get_package':
								app = getAppByPackageName(app_info['pkg_name']);
								if(app){
									RunTimes = 0;
									goApp(app_info);
									RunTime = app_info['timestamp'];
								}else if(confirm("您没有安装"+Url.decode(app_info['app_name'])+"，需要下载安装吗?")){
									//widget.openURL(Url.decode(app_info['down_url']));
									RunTimes = 0;
									var download_iframe = document.createElement('iframe');
									download_iframe.style.display = 'none';
									download_iframe.src = Url.decode(app_info['down_url']);
									document.body.appendChild(download_iframe);
									widget.onshow = function() {goApp(app_info);};
									RunTime = app_info['timestamp'];
									//location.href=Url.decode(app_info['down_url']);
								}else RunTime = app_info['timestamp'];
								break;
							case 'go_to_search':
							case 'go_to_site':
								setReturnButton(Url.decode(app_info['url']));
								break;
							case 'share_with_friend':
								startEditor('', send_msg);
								RunTime = app_info['timestamp'];
								break;
							default:
								showMsg(app_info, tips);
								break;
						}
						
					}
				} catch(e) {};  
			}  
			setInterval(checkAction, 1000); 
			
			function goApp(appInfo){
				var tmp_app = getAppByPackageName(appInfo['pkg_name']);
				if(tmp_app&&!RunTimes){
					if(confirm("您已经安装"+Url.decode(appInfo['app_name'])+"，需要运行吗?")){
						RunTimes = 1;
						runApp(tmp_app);
					}
				}
			}
			
			function setReturnButton(return_url){
				window.menu.setRightSoftkeyLabel('返回', function(){
					window.menu.setRightSoftkeyLabel('退出',function(){
						exit_widget();
					});
					document.getElementById("mainframe").src = return_url;
				});
			}

			function showMsg(info, tips){
				if(!info) return false;
				var str = '';
				 
				for(var item in info){
					str += item;
				}
				
				alert(tips+':'+window.mainframe.location.hash+'='+str);
			}
			
			function showLoading(){
				var container_div=document.createElement("div");
				container_div.id = "container";

				var window_div=document.createElement("div");
				window_div.className = "loading";
				window_div.innerHTML = '<img src="images/loading.gif" />';
				
				document.body.appendChild(container_div);
				document.body.appendChild(window_div);
			}

			function getInfo(data){
				if(!data) return false;
				var result = new Array();
				var arr=data.split("|");

				for(var i = 0; i<arr.length; i++){
					var tmp_str = arr[i];
					var item = tmp_str.split("=");
					result[item[0]] = item[1];
				}

				return result;
			}

			function runApp(app){
				var opt = new Object();
				opt.Mode = "Standalone";

				var criteria = new Object();
				criteria.ApplicationID = "s60uid://"+app['Uid'];
				criteria.Option = opt;

				so.IAppManager.LaunchApp(criteria);
			}

			function getAppByPackageName(pkg_name){
				var list = getAppList();
				for(var i = 0;  i<list.length; i++){
					if(list[i]['Path'].indexOf(pkg_name)>0) return list[i];
				}

				return false;
			}

			function getAppList(){
				var criteria = new Object;
				criteria.Type = 'Application';
				so = device.getServiceObject("Service.AppManager", "IAppManager");
				var result = so.IAppManager.GetList(criteria);
				return getIterableList(result.ReturnValue);
			}

			function getIterableList(iterator)
			{
			  var list = new Array();
			  try
			  {
				iterator.reset();
				var item;
				var i = 0;
				while (( item = iterator.getNext()) != undefined ){
					var app_item = new Array();
					list[i] = getObject( item, app_item);
					i++;
				}
			  }
			  catch(e)
			  {
				alert('QshowIterableListZ ' + e);
			  }
			  return list;
			}

			function getObject( obj, app_item )
			{
			  try { 
				if ( typeof obj != 'object' )
				  return obj;
				else {
				  for(var key in obj) {
					app_item[key] = getObject( obj[key], app_item );
				  }
				}
			  } 
			  catch (e) 
			  {
				alert("getObject: " + e);
			  }
			  return app_item;
			}
			
			function startEditor(number, message){
				var messaging = null;
				try {
					messaging = nokia.device.load("messaging");
				}
				catch(e) {
					//alert(e);
				}
			    var message = {
			        type: 'SMS',
			        to: [number],
			        body: message
			    };
				try{
				    messaging.startEditor(message);
				}catch(e){
					//alert(e.toString());
				}
			}
			
			function send_to_friend(){
				startEditor('', send_msg);
			}
			
			function check_update(){
				var xmlhttp = getXmlHttp();
				if(window.netscape) {
			    	netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");        
				}
				var url = update_url;
				xmlhttp.open("GET", url, true);
				xmlhttp.onreadystatechange = function ()
				{
					if (xmlhttp.readyState == 4)
					{
						if (xmlhttp.status == 200) 
						{
							if(xmlhttp.responseText == 0){
								 alert('该应用已经是最新版本！');
							}
							else if(xmlhttp.responseText.slice(0,1) == '<'){check_update();}
							else
							{
								if(confirm("\u68C0\u6D4B\u5230\u65B0\u7248\u672C\uFF0C\u662F\u5426\u8FDB\u5165\u4E0B\u8F7D\u9875\u9762?"))
								{
									widget.openURL(xmlhttp.responseText);
									var WRT = window.open("", "_top");
									WRT.close();
								}else{}
							}
						}
					}
				};
				xmlhttp.send(null);
				function getXmlHttp()
				{
					var xml_http ;
					try 
					{
						// Firefox, Opera 8.0+, Safari
						xml_http = new XMLHttpRequest();
					} catch (e) 
					{
						// Internet Explorer
						try 
						{
							xml_http = new ActiveXObject("Msxml2.XMLHTTP");
						} catch (e) 
						{
							xml_http = new ActiveXObject("Microsoft.XMLHTTP");
						}
					}
					return xml_http;
				}
			}